# Maintainer: Celeste <cielesti@protonmail.com>
maintainer="Celeste <cielesti@protonmail.com>"
pkgname=yeti
pkgver=1.1
pkgrel=0
pkgdesc="ML-like functional language for the JVM"
url="https://mth.github.io/yeti/"
# riscv64: blocked by apache-ant & openjdk8
arch="noarch !riscv64"
license="BSD-3-Clause"
_jdkbuild=8
makedepends="apache-ant openjdk$_jdkbuild-jdk"
source="https://github.com/mth/yeti/archive/refs/tags/v$pkgver/yeti-$pkgver.tar.gz"

case "$CARCH" in
	# Newer Java is not supported on 32bit.
	x86|arm*) depends="$depends openjdk8-jre-base" ;;
	*) depends="$depends java-jre-headless" ;;
esac

build() {
	export JAVA_HOME="/usr/lib/jvm/java-$_jdkbuild-openjdk"
	export PATH="$JAVA_HOME/bin:$PATH"

	ant jar
}

check() {
	ant test
}

package() {
	install -Dm755 /dev/stdin "$pkgdir"/usr/bin/yeti <<-EOF
	#!/bin/sh
	exec java -jar /usr/share/java/yeti.jar "\$@"
	EOF

	install -Dvm644 yeti.jar \
		"$pkgdir"/usr/share/java/yeti-$pkgver.jar
	ln -s yeti-$pkgver.jar "$pkgdir"/usr/share/java/yeti.jar

	install -Dvm644 yeti-lib.jar \
		"$pkgdir"/usr/share/java/yeti-lib-$pkgver.jar
	ln -s yeti-lib-$pkgver.jar "$pkgdir"/usr/share/java/yeti-lib.jar
}

sha512sums="
68461a077ce0c24b559df7e7518ff680778e62b42f548495d8c92f00b8ac5f2474e5482f509d8a38171fcefc129b85db4600dc2d1cf8ef7d6ce88cad5db71777  yeti-1.1.tar.gz
"
